"""
汽车制造：你需要一辆汽车，只需从工厂提货，而不需要关心汽车的制造过程及其内部实现。
"""
from abc import ABC, abstractmethod


# 抽象产品 A
class Car(ABC):
    @abstractmethod
    def run(self):
        pass


# 具体产品 A1
class PassengerCar(Car):
    def run(self):
        print(f'PassengerCar running...')


# 具体产品 A2
class FreightCar(Car):
    def run(self):
        print('FreightCar running...')


# 具体产品 A3
class SpecialCar(Car):
    def run(self):
        print('SpecialCar running...')


# 具体工厂
class CarFactory:
    def get_car(self, car):
        if car is None:
            return None

        if car.upper() == 'PassengerCar'.upper():
            return PassengerCar()
        elif car.upper() == 'FreightCar'.upper():
            return FreightCar()
        elif car.upper() == 'SpecialCar'.upper():
            return SpecialCar()

        return None


if __name__ == '__main__':
    factory = CarFactory()
    passenger_car = factory.get_car('PassengerCar')
    freight_car = factory.get_car('FreightCar')
    special_car = factory.get_car('SpecialCar')
    passenger_car.run()
    freight_car.run()
    special_car.run()
